package controllers

import (
	"ktvserver/config"
	"ktvserver/ktvdownloadserver"
	"ktvserver/ktvutil"
	"time"
)

var (
	startupDate time.Time
)

func init() {
	startupDate = time.Now()
}

type StatusController struct {
	UserController
}

func (c *StatusController) Get() {
	c.TplNames = "status"
	c.Data["title"] = "系统状态"

	c.Data["startupDate"] = startupDate

	c.Data["version"] = config.Version

	// 互联网IP地址
	c.Data["internetip"] = ktvutil.GetInternetCacheAddress()

	// 歌曲下载次数
	c.Data["downloadSongCount"] = ktvutil.GetDownloadSongCount()

	// 已经发送字节数
	c.Data["sentBytes"] = ktvdownloadserver.GetSentBytes()
	c.Data["recvBytes"] = ktvdownloadserver.GetRecvBytes()

	// 动态域名设置
	ddns_name, ddns_key, isEnable := ktvutil.GetDDnsParam()
	c.Data["ddns_name"] = ddns_name
	c.Data["ddns_key"] = ddns_key

	if isEnable {
		c.Data["ddns_enable"] = 1
	} else {
		c.Data["ddns_enable"] = 0
	}

}
